home *** CD-ROM | disk | FTP | other *** search
/ Gamers Delight 2 / Gamers Delight 2.iso / Aminet / game / misc / attacks.lzh / Attacks / Sources / attacksgraphics.mod < prev    next >
Text File  |  1992-04-15  |  45KB  |  1,089 lines

  1. IMPLEMENTATION MODULE attacksgraphics;
  2.  
  3. (*$R-V-*) (* range checking OFF, overflow checking OFF *)
  4.  
  5. (* This is the implementation module of all the graphics stuff for my
  6.   ataxx program.
  7. *)
  8.  
  9. (**************************************************************)
  10. FROM TermInOut
  11.   IMPORT   WriteString, WriteLn;
  12.  
  13. FROM SYSTEM
  14.   IMPORT   BYTE, ADR, LONGWORD, ADDRESS;
  15.  
  16. FROM Memory
  17.   IMPORT   AllocMem, FreeMem, MemReqSet, MemChip, MemClear;
  18.  
  19. FROM Preferences
  20.   IMPORT   Preferences, GetPrefs;
  21.  
  22. FROM Views
  23.   IMPORT   ViewModesSet, Sprites, LoadRGB4, SetRGB4, ViewPort, ColorTable,
  24.            GetRGB4;
  25.  
  26. FROM Rasters
  27.   IMPORT   RastPort, Jam1, Jam2;
  28.  
  29. FROM Drawing
  30.   IMPORT   SetAPen, SetOPen, SetDrMd, Draw, Move, RectFill, DrawCircle,
  31.            WritePixel, ReadPixel;
  32.  
  33. FROM header
  34.   IMPORT   boardtype, playertype, squaretype, boardrange, state, pointercode,
  35.            movetype, printmsgtype;
  36.  
  37. FROM input
  38.   IMPORT   WaitForMouseUp, ChangeToMainMenu;
  39.  
  40. FROM attackssprites
  41.   IMPORT   InitPointers, circle, mypointer, emptysquare, blocksquare;
  42.  
  43. FROM Ports
  44.   IMPORT   GetMsg, ReplyMsg, MsgPortPtr, WaitPort, MessagePtr;
  45.  
  46. FROM Conversions
  47.   IMPORT   ConvNumberToString;
  48.  
  49. FROM Intuition
  50.   IMPORT   NewScreen, OpenScreen, ScreenPtr, Screen, CustomScreen,
  51.            CloseScreen, NewWindow, WindowPtr, WindowFlagsSet,
  52.            IDCMPFlagsSet, OpenWindow, CloseWindow, ClearMenuStrip,
  53.            WindowFlags, IDCMPFlags, ScreenFlags, IntuiMessagePtr,
  54.            SetPointer, ClearPointer, IntuiText, PrintIText, ShowTitle;
  55.  
  56. (***********************************************************************)
  57.  
  58. CONST
  59.   Black = 0;
  60.   White = 1;
  61.   BGrey = 2;
  62.  
  63.   Red   = 3;     DarkRed = 4;      LtRed = 5;
  64.   Blue  = 6;     DarkBlue = 7;     LtBlue = 8;
  65.   HGrey = 9;     HDarkGrey = 10;   HLtGrey = 11;
  66.  
  67.   Green = 14;    DarkGreen = 13;   LtGreen = 12;     (* other colors *)
  68.   Yellow = 15;   DarkYellow = 16;  LtYellow = 18;
  69.   Orange = 18;   DarkOrange = 19;  LtOrange = 20;
  70.   Purple = 21;   DarkPurple = 22;  LtPurple = 23;
  71.   Violet = 24;   DarkViolet = 25;  LtViolet = 26;
  72.   Cyan = 27;     DarkCyan = 28;    LtCyan = 29;
  73.  
  74. VAR
  75.   ns : NewScreen;               (* The screen and graphics vars  *)
  76.   myscreenptr : ScreenPtr;
  77.   myrastport : RastPort;
  78.   myviewport : ViewPort;
  79.   mycolortable : ColorTable;
  80.  
  81.   nw : NewWindow;               (* The backdrop window vars      *)
  82.  
  83.   itext : IntuiText;            (* For displaying text  *)
  84.  
  85.   oldmousecolor1, oldmousecolor2, oldmousecolor3 :   (* Hold the colors  *)
  86.      ARRAY [1..3] OF CARDINAL;                       (* of the original   *)
  87.                                                      (* mouse.            *)
  88.  
  89. (**************************************************************************)
  90.  
  91. PROCEDURE InitializeScreen() : BOOLEAN;
  92.  
  93. (*      Starts the graphix running.                                    *)
  94. (* Sets up all the graphics variables and draws the first graphics     *)
  95. (* that will be presented.  It returns true if all the actions worked, *)
  96. (* false otherwise.                                                    *)
  97. (*                                                                     *)
  98. (*   INPUT                                                             *)
  99. (*            n/a                                                      *)
  100. (*                                                                     *)
  101. (*   OUTPUT                                                            *)
  102. (*            Returns a boolean value that tells if the operation was  *)
  103. (*            succussful or not.  If successful, the screen (along     *)
  104. (*            with the accompanying graphics) is started.              *)
  105. (*                                                                     *)
  106. (*   NOTE:    This uses mostly globals to this module.  It should      *)
  107. (*            work fine.                                               *)
  108.  
  109. VAR
  110.   i : CARDINAL;
  111.   oldcolor : LONGCARD;             (* holds the initial result of GetRGB4 *)
  112.   preferences : Preferences;
  113.   foo : ADDRESS;
  114.  
  115. BEGIN
  116.       (*******************************)
  117.       (* Making new screen structure *)
  118.       (*******************************)
  119.  
  120.   ns.LeftEdge := 0; ns.TopEdge := 0;
  121.   ns.Width := 320; ns.Height := 200;
  122.   ns.Depth := 4;
  123.   ns.DetailPen := BYTE(0); ns.BlockPen := BYTE(1);
  124.   ns.ViewModes := ViewModesSet{Sprites};    (* Not quite sure about this *)
  125.   ns.Type := CustomScreen;
  126.   ns.Font := NIL;                           (* Using default font *)
  127.   ns.DefaultTitle := ADR("Attacks");
  128.   ns.Gadgets := NIL;
  129.  
  130.   myscreenptr := OpenScreen(ns);
  131.   IF myscreenptr = NIL THEN
  132.      WriteString ("Couldn't open screen."); WriteLn;
  133.      RETURN FALSE;
  134.      END;
  135.  
  136.   ShowTitle(myscreenptr^, FALSE);     (* Put title BEHIND the backdrop's *)
  137.  
  138.  
  139.         (**************************************)
  140.         (* Get vars for the graphics routines *)
  141.         (**************************************)
  142.  
  143.   myrastport := myscreenptr^.RastPort;
  144.   myviewport := myscreenptr^.ViewPort;
  145.  
  146.   foo := GetPrefs(ADR(preferences), SIZE(Preferences));
  147.            (* Here, I'm getting the default colors for the orig. mouse *)
  148.   oldmousecolor1[1] := preferences.color17 DIV 128;
  149.   oldmousecolor1[2] := preferences.color17 DIV 8;
  150.   oldmousecolor1[3] := preferences.color17;
  151.   oldmousecolor2[1] := preferences.color18 DIV 128;
  152.   oldmousecolor2[2] := preferences.color18 DIV 8;
  153.   oldmousecolor2[3] := preferences.color18;
  154.   oldmousecolor3[1] := preferences.color19 DIV 128;
  155.   oldmousecolor3[2] := preferences.color19 DIV 8;
  156.   oldmousecolor3[3] := preferences.color19;
  157.  
  158.         (************************************)
  159.         (* Preparing the ColorMap structure *)
  160.         (************************************)
  161.  
  162.                                       (* Defining the colors *)
  163.   mycolortable [0] := 0000H;   (* Black *)
  164.   mycolortable [1] := 0FFFH;   (* White *)
  165.   mycolortable [2] := 0AAAH;   (* BGrey *)
  166.   mycolortable [3] := 0D00H;   (* Red *)
  167.   mycolortable [4] := 0900H;   (* Dark Red *)
  168.   mycolortable [5] := 0F55H;   (* Light Red *)
  169.   mycolortable [6] := 024EH;   (* Blue *)
  170.   mycolortable [7] := 000AH;   (* Dark Blue *)
  171.   mycolortable [8] := 066FH;   (* Light Blue *)
  172.   mycolortable [9] := 0666H;   (* HGrey *)
  173.   mycolortable [10] := 0444H;   (* HDark Grey *)
  174.   mycolortable [11] := 0888H;   (* HLight Grey *)
  175.   mycolortable [12] := 09F9H;   (* Light Green *)
  176.   mycolortable [13] := 0090H;   (* Dark Green *)
  177.   mycolortable [14] := 00E0H;   (* Green *)
  178.   mycolortable [15] := 0EE0H;   (* Yellow *)
  179.  
  180.                                       (* This changes the colors *)
  181.   LoadRGB4 (myviewport, ADR (mycolortable), 16);
  182.  
  183.  
  184.         (*******************************)
  185.         (* Now, open a backdrop window *)
  186.         (*******************************)
  187.  
  188.   nw.LeftEdge := 0; nw.TopEdge := 0;
  189.   nw.Width := 320; nw.Height := 200;
  190.   nw.DetailPen := BYTE(-1); nw.BlockPen := BYTE(-1);  (* use screen's pens *)
  191.   nw.Flags := WindowFlagsSet {BackDrop, Borderless, Activate};
  192.   nw.IDCMPFlags := IDCMPFlagsSet {MouseButtons, MenuPick};
  193.   nw.FirstGadget := NIL;
  194.   nw.CheckMark := NIL;
  195.   nw.Title := NIL;                       (* NO TITLE *)
  196.   nw.Type := CustomScreen;
  197.   nw.Screen := myscreenptr;
  198.  
  199.   mywindowptr := OpenWindow(nw);
  200.   IF mywindowptr = NIL THEN
  201.      CloseScreen(myscreenptr^);
  202.      WriteString ("Couldn't open window."); WriteLn;
  203.      RETURN FALSE;
  204.      END;
  205.  
  206.         (***************************)
  207.         (* Draw the initial screen *)
  208.         (***************************)
  209.  
  210. (* Set the drawing mode *)
  211.   SetDrMd(myrastport, Jam1);
  212.  
  213. (* Blank the screen *)
  214.   SetAPen(myrastport, Black);      (* set A pen *)
  215.   SetOPen(myrastport, Black);      (* and the outline pen too! *)
  216.   RectFill(myrastport,0,0,319,199);
  217.  
  218. (* Drawing a blank board *)
  219. SetAPen(myrastport, BGrey);
  220.   SetOPen(myrastport, BGrey);
  221.   RectFill(myrastport,52,18,267,198);
  222.  
  223.   i := 82;                         (* draw vertical lines *)
  224.   SetAPen(myrastport, Black);      (* black *)
  225.   REPEAT
  226.      Move(myrastport, i, 18);
  227.      Draw(myrastport, i, 199);
  228.      i := i + 31;
  229.   UNTIL i = 268;
  230.  
  231.   i := 43;                         (* now the horizontal *)
  232.   REPEAT
  233.      Move(myrastport, 52, i);
  234.      Draw(myrastport, 268, i);
  235.      i := i + 26;
  236.   UNTIL i = 199;
  237.  
  238.            (*********************)
  239.            (* Put in the scores *)
  240.            (*********************)
  241.   itext.FrontPen := BYTE(Red);
  242.   itext.DrawMode := Jam1;
  243.   itext.LeftEdge := 10;   itext.TopEdge := 15;
  244.   itext.ITextFont := NIL;
  245.   itext.IText := ADR("SCORE");
  246.   itext.NextText := NIL;
  247.   PrintIText(myrastport,itext, 0, 0);
  248.  
  249.   itext.FrontPen := BYTE(Blue);
  250.   itext.LeftEdge := 270;
  251.   PrintIText(myrastport,itext, 0, 0);
  252.  
  253.  
  254.   RETURN InitPointers();           (* Lastly, set up the pointer sprites *)
  255. END InitializeScreen;
  256.  
  257.  
  258. (**************************************************************************)
  259.  
  260. PROCEDURE CleanupGraphics;
  261.  
  262. (*      Stops the graphix and deallocates all graphix allocated        *)
  263. (* memory.  It assumes that the graphics HAS been succussfully initi-  *)
  264. (* ated.                                                               *)
  265. (*                                                                     *)
  266. (*   INPUT                                                             *)
  267. (*            n/a                                                      *)
  268. (*                                                                     *)
  269. (*   OUTPUT                                                            *)
  270. (*            n/a                                                      *)
  271. (*                                                                     *)
  272. (*   NOTE:    This accesses and (hopefully) removes all the globals    *)
  273. (*            that were activated by the init procedure.               *)
  274.  
  275.  
  276. VAR i : CARDINAL;
  277.  
  278. BEGIN
  279.   FreeMem (ADDRESS(circle), 76);       (* deallocate sprite mem *)
  280.   FreeMem (ADDRESS(mypointer[red]), 76);
  281.   FreeMem (ADDRESS(mypointer[blue]), 76);
  282.   FreeMem (ADDRESS(emptysquare), 76);
  283.   FreeMem (ADDRESS(blocksquare), 76);
  284.  
  285.   CloseWindow(mywindowptr^);    (* With intuition, this is easy! *)
  286.   CloseScreen(myscreenptr^);
  287. END CleanupGraphics;
  288.  
  289.  
  290.  
  291. (***********************************************************************)
  292.  
  293. PROCEDURE DrawSquare (xloc : boardrange; yloc : boardrange;
  294.                       square : squaretype);
  295.  
  296. (*      This routine modifies only a single square, rather than the    *)
  297. (* whole board like the DrawBoard routine does.  Considering the upper *)
  298. (* left corner as square (1,1), this routine will replace the given    *)
  299. (* square with the specified item (either a block, empty, red, or      *)
  300. (* blue).                                                              *)
  301. (*                                                                     *)
  302. (*   INPUT                                                             *)
  303. (*            xloc, yloc     These two numbers describe the location   *)
  304. (*                           of the square to change.                  *)
  305. (*                                                                     *)
  306. (*            square         This tells the routine what to change     *)
  307. (*                           the square to.                            *)
  308. (*                                                                     *)
  309. (*                                                                     *)
  310. (*   OUTPUT                                                            *)
  311. (*                     The display is change so that only the square   *)
  312. (*                     indicated looks like the new type.              *)
  313.  
  314. VAR
  315.   x, y : CARDINAL;        (* The top left corner of the square   *)
  316.   foo : INTEGER;
  317.  
  318. BEGIN
  319.      (* First, find the upper left corner of the square in question *)
  320.   x := xloc * 31 + 21;
  321.   y := yloc * 26 - 8;
  322.  
  323.   CASE square OF
  324.      | empty  :
  325.            SetAPen(myrastport, BGrey);
  326.            SetOPen(myrastport, BGrey);
  327.            RectFill(myrastport, x, y, x + 29, y + 24);
  328.  
  329.      | block  :
  330.            SetAPen(myrastport, HGrey);
  331.            SetOPen(myrastport, HGrey);
  332.            RectFill(myrastport, x + 3, y + 3, x + 26, y + 21);
  333.            SetAPen(myrastport, HLtGrey);    (* highlight *)
  334.            Move(myrastport, x, y + 23);
  335.            Draw(myrastport, x, y);
  336.            Draw(myrastport, x + 29, y);
  337.            Move(myrastport, x + 28, y + 1);
  338.            Draw(myrastport, x + 1, y + 1);
  339.            Draw(myrastport, x + 1, y + 22);
  340.            Move(myrastport, x + 2, y + 21);
  341.            Draw(myrastport, x + 2, y + 2);
  342.            Draw(myrastport, x + 27, y + 2);
  343.            SetAPen(myrastport, HDarkGrey);    (* shading *)
  344.            Move(myrastport, x, y + 24);
  345.            Draw(myrastport, x + 29, y + 24);
  346.            Draw(myrastport, x + 29, y + 1);
  347.            Move(myrastport, x + 28, y + 2);
  348.            Draw(myrastport, x + 28, y + 23);
  349.            Draw(myrastport, x + 1, y + 23);
  350.            Move(myrastport, x + 2, y + 22);
  351.            Draw(myrastport, x + 27, y + 22);
  352.            Draw(myrastport, x + 27, y + 3);
  353.      | red    :
  354.            SetAPen(myrastport, BGrey);
  355.            SetOPen(myrastport, BGrey);
  356.            RectFill(myrastport, x, y, x + 29, y + 24);
  357.            SetAPen(myrastport, Red);
  358.            SetOPen(myrastport, Red);
  359.            RectFill(myrastport, x + 6, y + 4, x + 22, y + 20);
  360.  
  361.            Move(myrastport, x +  7, y +  3);   (* Innermost lines   *)
  362.            Draw(myrastport, x + 21, y +  3);
  363.            Move(myrastport, x + 23, y +  5);
  364.            Draw(myrastport, x + 23, y + 19);
  365.            Move(myrastport, x + 21, y + 21);
  366.            Draw(myrastport, x +  7, y + 21);
  367.            Move(myrastport, x +  5, y + 19);
  368.            Draw(myrastport, x +  5, y +  5);
  369.  
  370.            Move(myrastport, x +  9, y +  2);
  371.            Draw(myrastport, x + 19, y +  2);
  372.            Move(myrastport, x + 24, y +  7);
  373.            Draw(myrastport, x + 24, y + 17);
  374.            Move(myrastport, x + 19, y + 22);
  375.            Draw(myrastport, x +  9, y + 22);
  376.            Move(myrastport, x +  4, y + 17);
  377.            Draw(myrastport, x +  4, y +  7);
  378.  
  379.            SetAPen(myrastport, DarkRed);       (* Draw Outer circle *)
  380.            DrawCircle(myrastport, x + 14, y + 12, 11);
  381.            SetAPen(myrastport, Red);                 (* Correct the circle *)
  382.            foo := WritePixel(myrastport, x + 7, y + 4);
  383.            foo := WritePixel(myrastport, x + 21, y + 4);
  384.            foo := WritePixel(myrastport, x + 6, y + 5);
  385.            foo := WritePixel(myrastport, x + 22, y + 5);
  386.            foo := WritePixel(myrastport, x + 6, y + 19);
  387.            foo := WritePixel(myrastport, x + 7, y + 20);
  388.            SetAPen(myrastport, DarkRed);
  389.            foo := WritePixel(myrastport, x + 7, y + 3);
  390.            foo := WritePixel(myrastport, x + 21, y + 3);
  391.            foo := WritePixel(myrastport, x + 5, y + 5);
  392.            foo := WritePixel(myrastport, x + 23, y + 5);
  393.            foo := WritePixel(myrastport, x + 5, y + 19);
  394.            foo := WritePixel(myrastport, x + 23, y + 19);
  395.            foo := WritePixel(myrastport, x + 7, y + 21);
  396.            foo := WritePixel(myrastport, x + 21, y + 21);
  397.  
  398.            foo := WritePixel(myrastport, x + 16, y + 6);  (* put in shading *)
  399.            foo := WritePixel(myrastport, x + 17, y + 6);
  400.            foo := WritePixel(myrastport, x +  9, y +  8);
  401.            foo := WritePixel(myrastport, x + 10, y +  8);
  402.            foo := WritePixel(myrastport, x + 12, y +  8);
  403.            foo := WritePixel(myrastport, x + 13, y +  8);
  404.            foo := WritePixel(myrastport, x + 16, y +  8);
  405.            foo := WritePixel(myrastport, x + 12, y +  9);
  406.            foo := WritePixel(myrastport, x + 14, y +  9);
  407.            foo := WritePixel(myrastport, x +  9, y + 10);
  408.            foo := WritePixel(myrastport, x + 14, y + 10);
  409.            foo := WritePixel(myrastport, x +  7, y + 11);
  410.            foo := WritePixel(myrastport, x + 11, y + 11);
  411.            foo := WritePixel(myrastport, x +  8, y + 12);
  412.            foo := WritePixel(myrastport, x + 13, y + 12);
  413.            foo := WritePixel(myrastport, x +  8, y + 13);
  414.            foo := WritePixel(myrastport, x + 12, y + 13);
  415.            foo := WritePixel(myrastport, x + 24, y + 14);
  416.            foo := WritePixel(myrastport, x + 10, y + 15);
  417.            foo := WritePixel(myrastport, x + 12, y + 16);
  418.            foo := WritePixel(myrastport, x + 17, y + 21);
  419.            foo := WritePixel(myrastport, x + 18, y + 21);
  420.            Move(myrastport, x + 13, y + 5 );
  421.            Draw(myrastport, x + 15, y +  5);
  422.            Move(myrastport, x + 10, y + 6 );
  423.            Draw(myrastport, x + 14, y +  6);
  424.            Move(myrastport, x +  9, y +  7);
  425.            Draw(myrastport, x + 16, y +  7);
  426.            Move(myrastport, x + 17, y + 8 );
  427.            Draw(myrastport, x + 17, y + 10);
  428.            Move(myrastport, x +  7, y +  9);
  429.            Draw(myrastport, x + 10, y +  9);
  430.            Move(myrastport, x +  8, y + 10);
  431.            Draw(myrastport, x + 10, y + 12);
  432.            Move(myrastport, x + 15, y + 22);
  433.            Draw(myrastport, x + 17, y + 22);
  434.            Move(myrastport, x + 19, y + 21);
  435.            Draw(myrastport, x + 23, y + 17);
  436.            Move(myrastport, x + 22, y + 17);
  437.            Draw(myrastport, x + 24, y + 15);
  438.  
  439.            SetAPen(myrastport, LtRed);             (* Highlight circle *)
  440.            foo := WritePixel(myrastport, x + 13, y +  2);
  441.            foo := WritePixel(myrastport, x + 10, y +  3);
  442.            foo := WritePixel(myrastport, x + 19, y +  6);
  443.            foo := WritePixel(myrastport, x +  8, y +  7);
  444.            foo := WritePixel(myrastport, x + 21, y +  8);
  445.            foo := WritePixel(myrastport, x +  6, y +  9);
  446.            foo := WritePixel(myrastport, x + 19, y + 10);
  447.            foo := WritePixel(myrastport, x +  6, y + 11);
  448.            foo := WritePixel(myrastport, x + 15, y + 11);
  449.            foo := WritePixel(myrastport, x + 20, y + 11);
  450.            foo := WritePixel(myrastport, x + 23, y + 12);
  451.            foo := WritePixel(myrastport, x +  9, y + 13);
  452.            foo := WritePixel(myrastport, x + 18, y + 13);
  453.            foo := WritePixel(myrastport, x + 20, y + 13);
  454.            foo := WritePixel(myrastport, x + 16, y + 14);
  455.            foo := WritePixel(myrastport, x + 23, y + 14);
  456.            foo := WritePixel(myrastport, x +  6, y + 15);
  457.            foo := WritePixel(myrastport, x + 14, y + 15);
  458.            foo := WritePixel(myrastport, x + 18, y + 15);
  459.            foo := WritePixel(myrastport, x + 18, y + 16);
  460.            foo := WritePixel(myrastport, x +  8, y + 17);
  461.            foo := WritePixel(myrastport, x + 16, y + 17);
  462.            foo := WritePixel(myrastport, x + 13, y + 18);
  463.            foo := WritePixel(myrastport, x + 17, y + 18);
  464.            foo := WritePixel(myrastport, x +  9, y + 19);
  465.            foo := WritePixel(myrastport, x + 10, y + 19);
  466.            foo := WritePixel(myrastport, x + 12, y + 19);
  467.            foo := WritePixel(myrastport, x + 14, y + 19);
  468.            foo := WritePixel(myrastport, x + 17, y + 19);
  469.            foo := WritePixel(myrastport, x + 18, y + 19);
  470.            foo := WritePixel(myrastport, x + 13, y + 21);
  471.            foo := WritePixel(myrastport, x + 14, y + 21);
  472.            foo := WritePixel(myrastport, x + 16, y + 21);
  473.            Move(myrastport, x + 12, y + 3 );
  474.            Draw(myrastport, x + 15, y + 3 );
  475.            Move(myrastport, x +  8, y +  4);
  476.            Draw(myrastport, x + 17, y +  4);
  477.            Move(myrastport, x +  9, y +  5);
  478.            Draw(myrastport, x + 12, y +  5);
  479.            Move(myrastport, x + 16, y +  5);
  480.            Draw(myrastport, x + 18, y +  5);
  481.            Move(myrastport, x +  7, y +  5);
  482.            Draw(myrastport, x +  7, y +  8);
  483.            Move(myrastport, x +  6, y +  6);
  484.            Draw(myrastport, x +  9, y +  6);
  485.            Move(myrastport, x +  5, y +  8);
  486.            Draw(myrastport, x +  8, y +  8);
  487.            Move(myrastport, x +  5, y +  8);
  488.            Draw(myrastport, x +  5, y + 13);
  489.            Move(myrastport, x + 11, y + 20);
  490.            Draw(myrastport, x + 18, y + 20);
  491.            Move(myrastport, x + 19, y + 17);
  492.            Draw(myrastport, x + 19, y + 19);
  493.            Move(myrastport, x + 20, y + 16);
  494.            Draw(myrastport, x + 20, y + 18);
  495.            Move(myrastport, x + 21, y + 14);
  496.            Draw(myrastport, x + 21, y + 16);
  497.            Move(myrastport, x + 22, y + 11);
  498.            Draw(myrastport, x + 22, y + 15);
  499.  
  500.      | blue   :
  501.            SetAPen(myrastport, BGrey);
  502.            SetOPen(myrastport, BGrey);
  503.            RectFill(myrastport, x, y, x + 29, y + 24);
  504.            SetAPen(myrastport, Blue);
  505.            SetOPen(myrastport, Blue);
  506.            RectFill(myrastport, x + 6, y + 4, x + 22, y + 20);
  507.  
  508.            Move(myrastport, x +  7, y +  3);   (* Innermost lines   *)
  509.            Draw(myrastport, x + 21, y +  3);
  510.            Move(myrastport, x + 23, y +  5);
  511.            Draw(myrastport, x + 23, y + 19);
  512.            Move(myrastport, x + 21, y + 21);
  513.            Draw(myrastport, x +  7, y + 21);
  514.            Move(myrastport, x +  5, y + 19);
  515.            Draw(myrastport, x +  5, y +  5);
  516.  
  517.            Move(myrastport, x +  9, y +  2);
  518.            Draw(myrastport, x + 19, y +  2);
  519.            Move(myrastport, x + 24, y +  7);
  520.            Draw(myrastport, x + 24, y + 17);
  521.            Move(myrastport, x + 19, y + 22);
  522.            Draw(myrastport, x +  9, y + 22);
  523.            Move(myrastport, x +  4, y + 17);
  524.            Draw(myrastport, x +  4, y +  7);
  525.  
  526.            SetAPen(myrastport, DarkBlue);       (* Draw Outer circle *)
  527.            DrawCircle(myrastport, x + 14, y + 12, 11);
  528.            SetAPen(myrastport, Blue);                 (* Correct the circle *)
  529.            foo := WritePixel(myrastport, x + 7, y + 4);
  530.            foo := WritePixel(myrastport, x + 21, y + 4);
  531.            foo := WritePixel(myrastport, x + 6, y + 5);
  532.            foo := WritePixel(myrastport, x + 22, y + 5);
  533.            foo := WritePixel(myrastport, x + 6, y + 19);
  534.            foo := WritePixel(myrastport, x + 7, y + 20);
  535.            SetAPen(myrastport, DarkBlue);
  536.            foo := WritePixel(myrastport, x + 7, y + 3);
  537.            foo := WritePixel(myrastport, x + 21, y + 3);
  538.            foo := WritePixel(myrastport, x + 5, y + 5);
  539.            foo := WritePixel(myrastport, x + 23, y + 5);
  540.            foo := WritePixel(myrastport, x + 5, y + 19);
  541.            foo := WritePixel(myrastport, x + 23, y + 19);
  542.            foo := WritePixel(myrastport, x + 7, y + 21);
  543.            foo := WritePixel(myrastport, x + 21, y + 21);
  544.  
  545.            foo := WritePixel(myrastport, x + 16, y + 6);  (* put in shading *)
  546.            foo := WritePixel(myrastport, x + 17, y + 6);
  547.            foo := WritePixel(myrastport, x +  9, y +  8);
  548.            foo := WritePixel(myrastport, x + 10, y +  8);
  549.            foo := WritePixel(myrastport, x + 12, y +  8);
  550.            foo := WritePixel(myrastport, x + 13, y +  8);
  551.            foo := WritePixel(myrastport, x + 16, y +  8);
  552.            foo := WritePixel(myrastport, x + 12, y +  9);
  553.            foo := WritePixel(myrastport, x + 14, y +  9);
  554.            foo := WritePixel(myrastport, x +  9, y + 10);
  555.            foo := WritePixel(myrastport, x + 14, y + 10);
  556.            foo := WritePixel(myrastport, x +  7, y + 11);
  557.            foo := WritePixel(myrastport, x + 11, y + 11);
  558.            foo := WritePixel(myrastport, x +  8, y + 12);
  559.            foo := WritePixel(myrastport, x + 13, y + 12);
  560.            foo := WritePixel(myrastport, x +  8, y + 13);
  561.            foo := WritePixel(myrastport, x + 12, y + 13);
  562.            foo := WritePixel(myrastport, x + 24, y + 14);
  563.            foo := WritePixel(myrastport, x + 10, y + 15);
  564.            foo := WritePixel(myrastport, x + 12, y + 16);
  565.            foo := WritePixel(myrastport, x + 17, y + 21);
  566.            foo := WritePixel(myrastport, x + 18, y + 21);
  567.            Move(myrastport, x + 13, y + 5 );
  568.            Draw(myrastport, x + 15, y +  5);
  569.            Move(myrastport, x + 10, y + 6 );
  570.            Draw(myrastport, x + 14, y +  6);
  571.            Move(myrastport, x +  9, y +  7);
  572.            Draw(myrastport, x + 16, y +  7);
  573.            Move(myrastport, x + 17, y + 8 );
  574.            Draw(myrastport, x + 17, y + 10);
  575.            Move(myrastport, x +  7, y +  9);
  576.            Draw(myrastport, x + 10, y +  9);
  577.            Move(myrastport, x +  8, y + 10);
  578.            Draw(myrastport, x + 10, y + 12);
  579.            Move(myrastport, x + 15, y + 22);
  580.            Draw(myrastport, x + 17, y + 22);
  581.            Move(myrastport, x + 19, y + 21);
  582.            Draw(myrastport, x + 23, y + 17);
  583.            Move(myrastport, x + 22, y + 17);
  584.            Draw(myrastport, x + 24, y + 15);
  585.  
  586.            SetAPen(myrastport, LtBlue);             (* Highlight circle *)
  587.            foo := WritePixel(myrastport, x + 13, y +  2);
  588.            foo := WritePixel(myrastport, x + 10, y +  3);
  589.            foo := WritePixel(myrastport, x + 19, y +  6);
  590.            foo := WritePixel(myrastport, x +  8, y +  7);
  591.            foo := WritePixel(myrastport, x + 21, y +  8);
  592.            foo := WritePixel(myrastport, x +  6, y +  9);
  593.            foo := WritePixel(myrastport, x + 19, y + 10);
  594.            foo := WritePixel(myrastport, x +  6, y + 11);
  595.            foo := WritePixel(myrastport, x + 15, y + 11);
  596.            foo := WritePixel(myrastport, x + 20, y + 11);
  597.            foo := WritePixel(myrastport, x + 23, y + 12);
  598.            foo := WritePixel(myrastport, x +  9, y + 13);
  599.            foo := WritePixel(myrastport, x + 18, y + 13);
  600.            foo := WritePixel(myrastport, x + 20, y + 13);
  601.            foo := WritePixel(myrastport, x + 16, y + 14);
  602.            foo := WritePixel(myrastport, x + 23, y + 14);
  603.            foo := WritePixel(myrastport, x +  6, y + 15);
  604.            foo := WritePixel(myrastport, x + 14, y + 15);
  605.            foo := WritePixel(myrastport, x + 18, y + 15);
  606.            foo := WritePixel(myrastport, x + 18, y + 16);
  607.            foo := WritePixel(myrastport, x +  8, y + 17);
  608.            foo := WritePixel(myrastport, x + 16, y + 17);
  609.            foo := WritePixel(myrastport, x + 13, y + 18);
  610.            foo := WritePixel(myrastport, x + 17, y + 18);
  611.            foo := WritePixel(myrastport, x +  9, y + 19);
  612.            foo := WritePixel(myrastport, x + 10, y + 19);
  613.            foo := WritePixel(myrastport, x + 12, y + 19);
  614.            foo := WritePixel(myrastport, x + 14, y + 19);
  615.            foo := WritePixel(myrastport, x + 17, y + 19);
  616.            foo := WritePixel(myrastport, x + 18, y + 19);
  617.            foo := WritePixel(myrastport, x + 13, y + 21);
  618.            foo := WritePixel(myrastport, x + 14, y + 21);
  619.            foo := WritePixel(myrastport, x + 16, y + 21);
  620.            Move(myrastport, x + 12, y + 3 );
  621.            Draw(myrastport, x + 15, y + 3 );
  622.            Move(myrastport, x +  8, y +  4);
  623.            Draw(myrastport, x + 17, y +  4);
  624.            Move(myrastport, x +  9, y +  5);
  625.            Draw(myrastport, x + 12, y +  5);
  626.            Move(myrastport, x + 16, y +  5);
  627.            Draw(myrastport, x + 18, y +  5);
  628.            Move(myrastport, x +  7, y +  5);
  629.            Draw(myrastport, x +  7, y +  8);
  630.            Move(myrastport, x +  6, y +  6);
  631.            Draw(myrastport, x +  9, y +  6);
  632.            Move(myrastport, x +  5, y +  8);
  633.            Draw(myrastport, x +  8, y +  8);
  634.            Move(myrastport, x +  5, y +  8);
  635.            Draw(myrastport, x +  5, y + 13);
  636.            Move(myrastport, x + 11, y + 20);
  637.            Draw(myrastport, x + 18, y + 20);
  638.            Move(myrastport, x + 19, y + 17);
  639.            Draw(myrastport, x + 19, y + 19);
  640.            Move(myrastport, x + 20, y + 16);
  641.            Draw(myrastport, x + 20, y + 18);
  642.            Move(myrastport, x + 21, y + 14);
  643.            Draw(myrastport, x + 21, y + 16);
  644.            Move(myrastport, x + 22, y + 11);
  645.            Draw(myrastport, x + 22, y + 15);
  646.  
  647.   END;
  648.  
  649. END DrawSquare;
  650.  
  651.  
  652. (***********************************************************************)
  653.  
  654. PROCEDURE HighlightSquare (xloc : boardrange; yloc : boardrange;
  655.                       player : playertype);
  656.  
  657. (*      This routine highlights the given square in the color of the   *)
  658. (* specified player.  It is assumed that checking has already been     *)
  659. (* made so that the highlighting makes sense.                          *)
  660. (*                                                                     *)
  661. (*   INPUT                                                             *)
  662. (*            xloc, yloc     These two numbers describe the location   *)
  663. (*                           of the square to change.                  *)
  664. (*                                                                     *)
  665. (*            player         This tells the routine what colors to     *)
  666. (*                           use.                                      *)
  667. (*                                                                     *)
  668. (*                                                                     *)
  669. (*   OUTPUT                                                            *)
  670. (*                     The display is change so that only the square   *)
  671. (*                     indicated looks highlighted.                    *)
  672.  
  673. VAR
  674.   x, y : CARDINAL;        (* The top left corner of the square   *)
  675.  
  676. BEGIN
  677.      (* First, find the upper left corner of the square in question *)
  678.   x := xloc * 31 + 21;
  679.   y := yloc * 26 - 8;
  680.  
  681.      (* Now, change the color of the border of the square *)
  682.   IF player = red THEN
  683.      SetAPen(myrastport, Red);
  684.      ELSE SetAPen(myrastport, Blue);
  685.      END;
  686.   Move(myrastport, x - 1,  y - 1);
  687.   Draw(myrastport, x + 30, y - 1);
  688.   Draw(myrastport, x + 30, y + 25);
  689.   Draw(myrastport, x - 1,  y + 25);
  690.   Draw(myrastport, x - 1,  y - 1);
  691.   Move(myrastport, x    ,  y    );
  692.   Draw(myrastport, x + 29, y    );
  693.   Draw(myrastport, x + 29, y + 24);
  694.   Draw(myrastport, x    ,  y + 24);
  695.   Draw(myrastport, x    ,  y    );
  696.  
  697. (*
  698.   IF player = red THEN                (* Do the highlighting *)
  699.      SetAPen(myrastport, DarkRed);
  700.      ELSE SetAPen(myrastport, DarkBlue);
  701.      END;
  702.  
  703. Move(myrastport, x + 4, y + 7);    Draw(myrastport, x + 9, y + 2);
  704. Move(myrastport, x + 3, y +10);    Draw(myrastport, x +12, y + 1);
  705. Move(myrastport, x + 3, y +12);    Draw(myrastport, x +14, y + 1);
  706. Move(myrastport, x + 3, y +14);    Draw(myrastport, x +16, y + 1);
  707. Move(myrastport, x + 4, y +15);    Draw(myrastport, x +17, y + 2);
  708. Move(myrastport, x + 4, y +17);    Draw(myrastport, x +19, y + 2);
  709. Move(myrastport, x + 5, y +18);    Draw(myrastport, x +20, y + 3);
  710. Move(myrastport, x + 6, y +19);    Draw(myrastport, x +21, y + 4);
  711. Move(myrastport, x + 7, y +20);    Draw(myrastport, x +22, y + 5);
  712. Move(myrastport, x + 8, y +21);    Draw(myrastport, x +23, y + 6);
  713. Move(myrastport, x + 9, y +22);    Draw(myrastport, x +24, y + 7);
  714. Move(myrastport, x +11, y +22);    Draw(myrastport, x +24, y + 9);
  715. Move(myrastport, x +12, y +23);    Draw(myrastport, x +25, y +10);
  716. Move(myrastport, x +14, y +23);    Draw(myrastport, x +25, y +12);
  717. Move(myrastport, x +16, y +23);    Draw(myrastport, x +25, y +14);
  718. Move(myrastport, x +19, y +22);    Draw(myrastport, x +24, y +17);
  719. *)
  720.  
  721. END HighlightSquare;
  722.  
  723.  
  724. (***********************************************************************)
  725.  
  726. PROCEDURE UnHighlightSquare (xloc : boardrange; yloc : boardrange;
  727.                              player : playertype);
  728.  
  729. (*      This routine UNhighlights the given square.  It undoes the     *)
  730. (* effects of HighlightSquare.  Similarly, it assumes that checking    *)
  731. (* has already been done so that unhighlighting makes sense.           *)
  732. (*                                                                     *)
  733. (*   INPUT                                                             *)
  734. (*            xloc, yloc     These two numbers describe the location   *)
  735. (*                           of the square to change.                  *)
  736. (*                                                                     *)
  737. (*            player         This is the color of the square to UN-    *)
  738. (*                           highlight.                                *)
  739. (*                                                                     *)
  740. (*   OUTPUT                                                            *)
  741. (*                     The display is change so that only the square   *)
  742. (*                     indicated looks UNhighlighted.                  *)
  743.  
  744. VAR
  745.   x, y : CARDINAL;        (* The top left corner of the square   *)
  746.  
  747. BEGIN
  748.      (* First, find the upper left corner of the square in question *)
  749.   x := xloc * 31 + 21;
  750.   y := yloc * 26 - 8;
  751.  
  752.   SetAPen(myrastport, Black);
  753.   Move(myrastport, x - 1,  y - 1);
  754.   Draw(myrastport, x + 30, y - 1);
  755.   Draw(myrastport, x + 30, y + 25);
  756.   Draw(myrastport, x - 1,  y + 25);
  757.   Draw(myrastport, x - 1,  y - 1);
  758.   SetAPen(myrastport, BGrey);
  759.   Move(myrastport, x    ,  y    );
  760.   Draw(myrastport, x + 29, y    );
  761.   Draw(myrastport, x + 29, y + 24);
  762.   Draw(myrastport, x    ,  y + 24);
  763.   Draw(myrastport, x    ,  y    );
  764.  
  765. (*
  766.   CASE state.board[xloc,yloc] OF             (* UnDo the highlighting *)
  767.      | red    :
  768.            SetAPen(myrastport, Red);
  769.      | blue   :
  770.            SetAPen(myrastport, Blue);
  771.      | empty  :
  772.            SetAPen(myrastport, BGrey);
  773.      | block  :
  774.            SetAPen(myrastport, Black);
  775.      END;
  776. Move(myrastport, x + 4, y + 7);    Draw(myrastport, x + 9, y + 2);
  777. Move(myrastport, x + 3, y +10);    Draw(myrastport, x +12, y + 1);
  778. Move(myrastport, x + 3, y +12);    Draw(myrastport, x +14, y + 1);
  779. Move(myrastport, x + 3, y +14);    Draw(myrastport, x +16, y + 1);
  780. Move(myrastport, x + 4, y +15);    Draw(myrastport, x +17, y + 2);
  781. Move(myrastport, x + 4, y +17);    Draw(myrastport, x +19, y + 2);
  782. Move(myrastport, x + 5, y +18);    Draw(myrastport, x +20, y + 3);
  783. Move(myrastport, x + 6, y +19);    Draw(myrastport, x +21, y + 4);
  784. Move(myrastport, x + 7, y +20);    Draw(myrastport, x +22, y + 5);
  785. Move(myrastport, x + 8, y +21);    Draw(myrastport, x +23, y + 6);
  786. Move(myrastport, x + 9, y +22);    Draw(myrastport, x +24, y + 7);
  787. Move(myrastport, x +11, y +22);    Draw(myrastport, x +24, y + 9);
  788. Move(myrastport, x +12, y +23);    Draw(myrastport, x +25, y +10);
  789. Move(myrastport, x +14, y +23);    Draw(myrastport, x +25, y +12);
  790. Move(myrastport, x +16, y +23);    Draw(myrastport, x +25, y +14);
  791. Move(myrastport, x +19, y +22);    Draw(myrastport, x +24, y +17);
  792. *)
  793. END UnHighlightSquare;
  794.  
  795.  
  796. (**************************************************************************)
  797.  
  798. PROCEDURE DrawBoard (board : boardtype);
  799.  
  800. (*      Replaces the current display with the given board.             *)
  801. (*                                                                     *)
  802. (*   INPUT                                                             *)
  803. (*            board       A variable of boardtype that describes the   *)
  804. (*                        contents of every location of a board.       *)
  805. (*                                                                     *)
  806. (*   OUTPUT                                                            *)
  807. (*            The screen is modified to display the contents of the    *)
  808. (*            input data.                                              *)
  809.  
  810. VAR
  811.   i, j : boardrange;
  812.   x, y : CARDINAL;        (* The top left corner of the square   *)
  813.  
  814. BEGIN
  815.  
  816.   FOR j := 1 TO 7 DO
  817.      FOR i := 1 TO 7 DO
  818.         x := i * 31 + 35;    (* Find the center of the square in question *)
  819.         y := j * 26 + 4;
  820.         CASE board[i,j] OF
  821.            | red    :
  822.               IF ReadPixel(myrastport, x, y) # Red THEN
  823.                  DrawSquare(i, j, red);
  824.                  END;
  825.            | blue   :
  826.               IF ReadPixel(myrastport, x, y) # Blue THEN
  827.                  DrawSquare(i, j, blue);
  828.                  END;
  829.            | empty  :
  830.               IF ReadPixel(myrastport, x, y) # BGrey THEN
  831.                  DrawSquare(i, j, empty);
  832.                  END;
  833.            | block  :
  834.               IF ReadPixel(myrastport, x, y) # HGrey THEN
  835.                  DrawSquare(i, j, block);
  836.                  END;
  837.            END; (* case *)
  838.      END;
  839.   END;
  840. END DrawBoard;
  841.  
  842.  
  843. (*************************************************************************)
  844.  
  845. PROCEDURE ChangePointer (code : pointercode);
  846.  
  847. (*      This changes the mouse pointer.  The code determines what the  *)
  848. (* pointer is changed to.                                              *)
  849. (*                                                                     *)
  850. (*   INPUT                                                             *)
  851. (*            code        This variable is of the enumerated type,     *)
  852. (*                        pointercode.  It consists of RedCircle,      *)
  853. (*                        BlueCircle, and Default.  The Default code   *)
  854. (*                        tells this routine to restore the pointer    *)
  855. (*                        to whatever it was when the program was      *)
  856. (*                        started.                                     *)
  857. (*                                                                     *)
  858. (*   OUTPUT                                                            *)
  859. (*            The mouse pointer is immediately changed to the desired  *)
  860. (*            pointer.                                                 *)
  861.  
  862. BEGIN
  863.   CASE code OF
  864.      |  RedCircle   :
  865.         SetRGB4 (myviewport, 18, 15, 5, 5);    (* Red *)
  866.         SetRGB4 (myviewport, 17, 13, 0, 0);    (* Lt Red   *)
  867.         SetRGB4 (myviewport, 19, 9, 0, 0);     (*  Dark Red *)
  868.         SetPointer(mywindowptr^, ADDRESS(circle), 16, 16, -7, -7);
  869.  
  870.      |  BlueCircle  :
  871.         SetRGB4 (myviewport, 18, 6, 6, 15);    (* Blue *)
  872.         SetRGB4 (myviewport, 17, 3, 4, 14);    (* Lt Blue   *)
  873.         SetRGB4 (myviewport, 19, 0, 0, 10);    (*  Dark Blue *)
  874.         SetPointer(mywindowptr^, ADDRESS(circle), 16, 16, -7, -7);
  875.  
  876.      |  RedPointer  :
  877.         SetRGB4 (myviewport, 17, 13, 0, 0);     (* red *)
  878.         SetRGB4 (myviewport, 18, 0, 0, 0);     (* black *)
  879.         SetRGB4 (myviewport, 19, 0, 0, 0);     (* black *)
  880.         SetPointer(mywindowptr^, ADDRESS(mypointer[red]), 10, 16, -1, -2);
  881.  
  882.      |  BluePointer :
  883.         SetRGB4 (myviewport, 17, 2, 4, 14);    (* blue *)
  884.         SetRGB4 (myviewport, 18, 2, 4, 14);    (* blue *)
  885.         SetRGB4 (myviewport, 19, 0, 0, 0);     (* black *)
  886.         SetPointer(mywindowptr^, ADDRESS(mypointer[blue]), 10, 16, -16, -2);
  887.  
  888.      |  DefaultPointer :
  889.         SetRGB4 (myviewport, 17, oldmousecolor1[1], oldmousecolor1[2], oldmousecolor1[3]);
  890.         SetRGB4 (myviewport, 18, oldmousecolor2[1], oldmousecolor2[2], oldmousecolor2[3]);
  891.         SetRGB4 (myviewport, 19, oldmousecolor3[1], oldmousecolor3[2], oldmousecolor3[3]);
  892.         ClearPointer(mywindowptr^);
  893.  
  894.      |  EmptySquare :
  895.         SetRGB4 (myviewport, 18, 10, 10, 10);
  896.         SetRGB4 (myviewport, 17, 0, 0, 0);
  897.         SetRGB4 (myviewport, 19, 0, 0, 0);
  898.         SetPointer(mywindowptr^, ADDRESS(emptysquare), 16, 16, -7, -7);
  899.  
  900.      |  BlockSquare :
  901.         SetRGB4 (myviewport, 18, 8, 8, 8);
  902.         SetRGB4 (myviewport, 17, 6, 6, 6);
  903.         SetRGB4 (myviewport, 19, 4, 4, 4);     (* This is color 11 *)
  904.         SetPointer(mywindowptr^, ADDRESS(blocksquare), 16, 16, -7, -7);
  905.      END;
  906.  
  907. END ChangePointer;
  908.  
  909.  
  910. (**************************************************************************)
  911.  
  912. PROCEDURE PrintTurn (player : playertype);
  913.  
  914. (*      Displays whose turn it is by the message on the top of the     *)
  915. (* screen                                                              *)
  916. (*                                                                     *)
  917. (*   INPUT                                                             *)
  918. (*            player      The player whose turn it now is.             *)
  919. (*                                                                     *)
  920. (*   OUTPUT                                                            *)
  921. (*            The screen is modified to display whose turn it is.      *)
  922. BEGIN
  923.         (* First, blank out the old message *)
  924.   itext.FrontPen := BYTE(Black);
  925.   itext.BackPen := BYTE(Black);
  926.   itext.DrawMode := Jam2;
  927.   itext.LeftEdge := 0;   itext.TopEdge := 0;
  928.   itext.ITextFont := NIL;
  929.   itext.IText := ADR("               ");
  930.   itext.NextText := NIL;
  931.   PrintIText(myrastport,itext, 117, 7);
  932.  
  933.   itext.FrontPen := BYTE(Black);
  934.   IF player = red THEN
  935.      itext.BackPen := BYTE(Red);
  936.      itext.IText := ADR("Red's Turn");
  937.      PrintIText(myrastport,itext, 121,7);
  938.   ELSE
  939.      itext.BackPen := BYTE(Blue);
  940.      itext.IText := ADR("Blue's Turn");
  941.      PrintIText(myrastport,itext, 117,7);
  942.   END;
  943. END PrintTurn;
  944.  
  945. (**************************************************************************)
  946. PROCEDURE PrintMsg (msg : printmsgtype);
  947.  
  948. (*   Prints the message at the top of the screen.  This procedure should  *)
  949. (* not be confused with the procedure PrintTurn, which displays who's     *)
  950. (* turn it is to play.                                                    *)
  951. (*                                                                        *)
  952. (*   INPUT                                                                *)
  953. (*            msg                  This is which message to display.      *)
  954. (*                                                                        *)
  955. (*   OUTPUT                                                               *)
  956. (*            The screen is changed to display the desired message.       *)
  957.  
  958. BEGIN
  959.         (* First, blank out the old message *)
  960.   itext.FrontPen := BYTE(Black);
  961.   itext.BackPen := BYTE(Black);
  962.   itext.DrawMode := Jam2;
  963.   itext.LeftEdge := 0;   itext.TopEdge := 0;
  964.   itext.ITextFont := NIL;
  965.   itext.IText := ADR("              ");
  966.   itext.NextText := NIL;
  967.   PrintIText(myrastport,itext, 117, 7);
  968.  
  969.   CASE msg OF
  970.      GameOver :
  971.         itext.FrontPen := BYTE(White);
  972.         itext.IText := ADR("Game Over");
  973.         PrintIText(myrastport, itext, 125,7);
  974.         |
  975.  
  976.      Thinking :
  977.         IF state.turn = red THEN
  978.            itext.FrontPen := BYTE(Red);
  979.            ELSE itext.FrontPen := BYTE(Blue);
  980.            END;
  981.         itext.IText := ADR("Thinking...");
  982.         PrintIText(myrastport, itext, 129,7);
  983.         |
  984.      END;
  985.  
  986. END PrintMsg;
  987.  
  988.  
  989. (**************************************************************************)
  990.  
  991. PROCEDURE ShowScore (redscore : CARDINAL; bluescore : CARDINAL);
  992.  
  993. (*      Displays the scores.                                           *)
  994. (*                                                                     *)
  995. (*   INPUT                                                             *)
  996. (*            redscore    The number of squares occupied by the red    *)
  997. (*                        player.                                      *)
  998. (*                                                                     *)
  999. (*            bluescore   The number of squares occupied by the blue   *)
  1000. (*                        player.                                      *)
  1001. (*                                                                     *)
  1002. (*   OUTPUT                                                            *)
  1003. (*            The screen is modified to display the scores.            *)
  1004.  
  1005. VAR
  1006.   str : ARRAY [1..8] OF CHAR;
  1007.  
  1008. BEGIN
  1009.         (* First, blank out the old scores *)
  1010.   itext.FrontPen := BYTE(Black);
  1011.   itext.BackPen := BYTE(Black);
  1012.   itext.DrawMode := Jam2;
  1013.   itext.LeftEdge := 0;   itext.TopEdge := 0;
  1014.   itext.ITextFont := NIL;
  1015.   itext.IText := ADR("  ");
  1016.   itext.NextText := NIL;
  1017.   PrintIText(myrastport,itext, 22, 25);
  1018.   PrintIText(myrastport,itext, 282, 25);
  1019.  
  1020.   itext.FrontPen := BYTE(Red);
  1021.   itext.DrawMode := Jam1;
  1022.   ConvNumberToString(str, LONGWORD(redscore), FALSE, 10, 2, " ");
  1023.   itext.IText := ADR(str);
  1024.   PrintIText(myrastport,itext, 23, 25);
  1025.  
  1026.   itext.FrontPen := BYTE(Blue);
  1027.   ConvNumberToString(str, LONGWORD(bluescore), FALSE, 10, 2, " ");
  1028.   itext.IText := ADR(str);
  1029.   PrintIText(myrastport,itext, 282, 25);
  1030.  
  1031. END ShowScore;
  1032.  
  1033.  
  1034. (**************************************************************************)
  1035. PROCEDURE ShowAbout;
  1036.  
  1037. (*   Simply displays a message about the programmer and then waits for *)
  1038. (* a mouse click to then erase this new display and return to the old  *)
  1039. (* one.                                                                *)
  1040.  
  1041. VAR
  1042.   i, j : boardrange;
  1043.  
  1044. BEGIN
  1045.   ClearMenuStrip( mywindowptr^ );
  1046.   SetAPen(myrastport,DarkGreen);           (* Draw the rectangle *)
  1047.   SetOPen(myrastport,Green);
  1048.   RectFill(myrastport,52,69,267,143);
  1049.  
  1050.   itext.FrontPen := BYTE(White);         (* Printing the text *)
  1051.   itext.DrawMode := Jam1;
  1052.   itext.LeftEdge := 56;   itext.TopEdge := 73;
  1053.   itext.ITextFont := NIL;
  1054.   itext.IText := ADR("ATTACKS");
  1055.   itext.NextText := NIL;
  1056.   PrintIText(myrastport,itext, 0, 0);
  1057.   itext.TopEdge := 93;
  1058.   itext.IText := ADR("was brought to you by");
  1059.   PrintIText(myrastport,itext, 0, 0);
  1060.   itext.TopEdge := 113;
  1061.   itext.IText := ADR("        Scott Biggs");
  1062.   PrintIText(myrastport,itext, 0, 0);
  1063.   itext.TopEdge := 123;
  1064.   itext.IText := ADR("        6313 Walnut Hills");
  1065.   PrintIText(myrastport,itext, 0, 0);
  1066.   itext.TopEdge := 133;
  1067.   itext.IText := ADR("        Austin, TX  78723");
  1068.   PrintIText(myrastport,itext, 0, 0);
  1069.  
  1070.   WaitForMouseUp;
  1071.  
  1072.   SetAPen(myrastport,Black);           (* Erase the rectangle *)
  1073.   SetOPen(myrastport,Black);
  1074.   RectFill(myrastport,52,69,267,143);
  1075.   FOR j := 3 TO 5 DO
  1076.      FOR i := 1 TO 7 DO
  1077.         DrawSquare(i,j,state.board[i,j]);
  1078.         END;
  1079.      END;
  1080.   ChangeToMainMenu;
  1081. END ShowAbout;
  1082.  
  1083.  
  1084. (***********************************************************************)
  1085.  
  1086.  
  1087.  
  1088. END attacksgraphics.
  1089.